//
//  ZXXBaseTableViewController.swift
//  Swift_Weibo
//
//  Created by 朱骁雄 on 16/4/9.
//  Copyright © 2016年 朱骁雄. All rights reserved.
//

import UIKit




class ZXXBaseTableViewController: UITableViewController {

    
    var userLogin = false
//    var userLogin = true
    
    override func loadView() {
        userLogin ? super.loadView() : setupVisitorView()
    }

//    //点击方法
//    @objc func didClickLogin(){
//        print("didClickLogin")
//    }
//    @objc func didClickRegister(){
//        print("didClickRegister")
//    }
    


    private func setupVisitorView(){
        
        view = visitorView
        
        visitorView.delegate = self
        
        if self is ZXXHomeTableViewController {
            visitorView.startRotation()
        } else if self is ZXXMessageTableViewController{
            visitorView.setupVisitorViewInfo("visitordiscover_image_message", message: "登录后，别人评论你的微博，发给你的消息，都会在这里收到通知")
        } else if self is ZXXDiscoverTableViewController {
            visitorView.setupVisitorViewInfo("visitordiscover_image_message", message: "登录后，最新、最热微博尽在掌握，不再会与实事潮流擦肩而过")
        } else if self is ZXXProfileTableViewController {
            visitorView.setupVisitorViewInfo("visitordiscover_image_profile", message: "登录后，你的微博、相册、个人资料会显示在这里，展示给别人")
        }
        
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: .Plain, target: self, action: Selector("visitorViewDidClickRegisterButton"))
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登陆", style: .Plain, target: self, action: Selector("visitorViewDidClickLoginButton"))
        
        
    }

    private lazy var visitorView : ZXXVisitorView =  ZXXVisitorView()
    
}

extension ZXXBaseTableViewController: ZXXVisitorViewDelegate {
    
    //代理方法
    
    func visitorViewDidClickRegisterButton() {
        print("visitorViewDidClickRegisterButton")
    }
    func visitorViewDidClickLoginButton() {
        
        let oauthVC = ZXXOauthViewController()
        
        let nav = UINavigationController(rootViewController: oauthVC)
        
        presentViewController(nav, animated: true, completion: nil)
        
        print("visitorViewDidClickLoginButton")
    }
    
    
    
}





